function S = insertStatement(Q, item_id, rule_id, value)

%Takes the above varialbles and creates a S3QL insert statement for an
%statement. Q is a struct as described in s3db_read with url and key

%ROmesh Stanislaus April 2009

if isnumeric(item_id)
    item_id = num2str(item_id);
end
if isnumeric(rule_id)
    rule_id = num2str(rule_id);
end
if isnumeric(value)
    value = num2str(value);
end

S1 = ['<S3QL><insert>statement</insert><where><item_id>',item_id,...
    '</item_id><rule_id>',rule_id,'</rule_id><value>',value,...
    '</value></where></S3QL>'];
Q.X = S1;

[A1,Q]=s3db_read(Q); % insert statement in deployment
%disp(A1); %uncomment to test%%%%%%%%%%
if str2num(A1.error_code)
    error(A1)
end

%pause(3);
S = A1;
